<?php
define('DIR', strtr(dirname(dirname(__FILE__)), array('\\'=>'/')).'/');
define('DIR_APP', DIR.'app/');
define('DIR_CLASS', DIR.'class/');
define('DIR_CONF', DIR.'conf/');
define('DIR_FUN', DIR.'fun/');
define('DIR_LIB', DIR.'lib/');
define('DIR_TPL', DIR.'tpl/');

$get = $_GET;
$post = $_POST;
$request = $_REQUEST;

$c = $get['c'] ? $get['c'] : 'index';
$c_arr = explode('_', strtr($c, array('../' => '', './' => '', '/' => '', '\\' => '')));

$f = $get['f'] ? $get['f'] : 'index/';
$f = explode('.', strtr($f, array('../' => '', './' => '', '/' => '', '\\' => '')));
$file = '';
foreach((array)$f as $v){
	if(!empty($v)){
		$file .= $v.'/';
	}
}

$classname = '';
foreach($c_arr as $v){
	$classname .= htmlspecialchars(ucwords(strtolower($v)), ENT_QUOTES, 'UTF-8').'_';
}
$classname = substr($classname, 0, -1);


if(!file_exists(DIR_APP.$file.$classname.'.app.php')){
	if(DEBUG){
		exit('文件：'.DIR_APP.$file.$classname.'.app.php 不存在');
	}else {
		header('HTTP/1.1 404 Not Found'); 
		header("status: 404 Not Found"); 
	}
}

require DIR_FUN.'source.fun.php';
require DIR_LIB.'Libs.class.php';